package com.thomasbrault.display 
{
	import flash.display.Sprite;
	import flash.events.Event;	

	/**
	 * @author thomas
	 */
	public class AbstractSprite extends Sprite
	{
		function AbstractSprite () 
		{
			addEventListener( Event.ADDED_TO_STAGE, __onAddedToStage );
			addEventListener( Event.REMOVED_FROM_STAGE, __onRemovedFromStage );	
		}
		
		/**
		 * added to stage
		 */
		private function __onAddedToStage ( e : Event ) : void 
		{
			_addedToStage();
			stage.addEventListener( Event.RESIZE, __onResize );
			__onResize(null);
		}
		
		/**
		 * 
		 */
		private function __onRemovedFromStage ( e : Event ) : void 
		{
			stage.removeEventListener( Event.RESIZE, __onResize );
			_removedFromStage();
		}
		
		
		/**
		* 
		*/
		private function __onResize( e : Event ) : void
		{
			_layout();
		}
		
		
		/**
		* clip is added to stage
		*/
		protected function _addedToStage ( ) : void
		{
			
		}
		
		/**
		* clip is remove from stage
		*/
		protected function _removedFromStage ( ) : void
		{
			
		}
		
		
		/**
		* Called function for the layout (when the clip is attached or on resize)
		*/
		protected function _layout ( ) : void
		{
			
		}
	}
}
